<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="/WEB-INF/view/common/tag.jsp" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>留言列表</title>

    <link rel="stylesheet" href="${baseurl}/lib/yueqain/css/yueqian.all.css" media="all">
</head>
<body class="yueqian-container">

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">展览馆名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="galleryName" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">展览名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="exhibitionName" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">用户名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="commentUserName" placeholder="" class="layui-input">
                </div>
                <button class="yueqian-btn yueqian-btn-md yueqian-btn-primary" lay-submit lay-filter="search">
                    <i class="layui-icon layui-icon-search"></i>
                    查询
                </button>
                <button type="reset" class="yueqian-btn yueqian-btn-md">
                    <i class="layui-icon layui-icon-refresh"></i>
                    重置
                </button>
            </div>


        </form>
    </div>
</div>

<div class="layui-card">
    <div class="layui-card-body">
        <table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
    </div>
</div>


<!--操作-->
<script type="text/html" id="tableTool">
    <a class="layui-btn layui-btn-xs" lay-event="replay">回复</a>
</script>


<script type="text/html" id="isOpenTpl">
    {{#if (d.isOpen == 0) { }}
    <span class="layui-green">未回复</span>
    {{# }else if(d.isOpen == 1){ }}
    <span class="layui-orange">回复</span>
    {{# } }}
</script>

<script type="text/html" id="galleryImageTpl">
    <a class="layui-blue" href="{{d.galleryImage}}" target="_blank">{{d.galleryImage}}</a>
</script>

<script src="${baseurl}/lib/layui/layui.js" charset="utf-8"></script>
<script src="${baseurl}/lib/layui_custom/Hlayui.js" charset="utf-8"></script>
<script>
    //JavaScript代码区域
    layui.use(['element', 'table', 'form', 'jquery', 'layer', 'layerCustom'], function () {
        var element = layui.element;
        table = layui.table,
            $ = layui.jquery,
            layerCustom = layui.layerCustom,
            layer = layui.layer,
            form = layui.form;

        var myTalbe = table.render({
            elem: '#tableId'
            , url: BaseUrl + 'exhibitionComment/list'
            , skin: 'line'
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
                , {field: 'galleryName', title: '展览馆名称'}
                , {field: 'exhibitionName', title: '展览名称'}
                , {field: 'commentUserName', title: '评论人'}
                , {field: 'commentContent', title: '评论内容'}
                , {field: 'isReply', title: '回复状态',align:'center',templet:"#isReplyTpl"}
                , {field: 'replyContent', title: '回复内容'}
                , {field: 'replyUserName', title: '回复人'}
                , {title: '操作', toolbar: '#tableTool', fixed: "right", align: "center"}
            ]]
            , page: true
        });

        form.on("submit(search)", function (data) {
            myTalbe.reload({
                where: data.field,
                page: {curr: 1}
            });
            return false;
        });

        table.on("tool(tableFilter)", function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case "update":
                    update(data);
                    break;
                case "del":
                    del(data);
                case "replay":
                    replay(data);
                    break;
            }
        });

        $('.operateTable .yueqian-btn').on('click', function () {
            var type = $(this).data('type');
            switch (type) {
                case "add":
                    add();
                    break;
            }
        });

        // function add() {
        //     layerCustom.open("添加展览馆", BaseUrl + 'galleryInfo/add', "700px", "450px", function (layero, index) {
        //
        //     }, function () {
        //         myTalbe.reload();
        //     })
        // }
        //
        // function update(data) {
        //     layerCustom.open("修改书籍", BaseUrl + 'galleryInfo/edit', "700px", "450px", function (layero, index) {
        //         var iframeWin = window[layero.find("iframe")[0]["name"]];
        //         iframeWin.initForm(data);
        //     }, function () {
        //         myTalbe.reload();
        //     })
        // }
        //
        // function del(data) {
        //     layerCustom.confirm("是否要删除该记录", function () {
        //         var loading = layer.load();
        //         var params = {
        //             id: data.id
        //         }
        //         $.ajax({
        //             url: BaseUrl + "galleryInfo/remove",
        //             data: params,
        //             dataType: 'json',
        //             type: 'post',
        //             success: function (result) {
        //                 layer.close(loading);
        //                 if (result.success) {
        //                     layerCustom.greenLaughMsg(result.msg, function () {
        //                         myTalbe.reload();
        //                     });
        //                 } else {
        //                     layerCustom.redCryMsg(result.msg);
        //                 }
        //             }
        //         })
        //     })
        // }

        function replay(data) {
            layer.prompt(function(val, index){
                $.ajax({
                    url: BaseUrl + "exhibitionComment/replay",
                    data: {
                        id:data.id,
                        exhibitionId:data.exhibitionId,
                        replyContent:val
                    },
                    dataType: 'json',
                    type: 'post',
                    success: function (result) {
                        if (result.success) {
                            layerCustom.greenLaughMsg(result.msg, function () {
                                myTalbe.reload();
                            });
                        } else {
                            layerCustom.redCryMsg(result.msg);
                        }
                    }
                })
                layer.close(index);
            });
        }
    });
</script>
</body>
</html>

